package com.gitee.qdbp.general.common.api.message.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import com.gitee.qdbp.base.annotation.DataIsolation;
import com.gitee.qdbp.base.annotation.OperateTraces;
import com.gitee.qdbp.base.enums.DataState;
import com.gitee.qdbp.general.common.enums.MessageState;
import com.gitee.qdbp.general.common.enums.MessageType;

/**
 * 系统消息实体类
 *
 * @author zhh
 * @version 170802
 */
@OperateTraces(id = "id")
@DataIsolation(enable = false)
public class SystemMessageBean implements Serializable {

    /** 版本序列号 **/
    private static final long serialVersionUID = 1L;

    /** 表名 **/
    public static final String TABLE = "gn_system_message";

    /** 消息ID **/
    private String id;

    /** 消息类型(0.通知) **/
    private MessageType type;

    /** 群组ID(两人对话时以双方的ID字符连接作为群组ID) **/
    private String groupId;

    /** 发送人ID **/
    private Integer senderId;

    /** 发送时间 **/
    private Date sendTime;

    /** 接收人ID **/
    private Integer receiverId;

    /** 标题 **/
    private String title;

    /** 内容 **/
    private String content;

    /** 读取时间 **/
    private Date readTime;

    /** 状态(0.未读|1.已读) **/
    private MessageState readState;

    /** 选项 **/
    private Map<String, Object> options;

    /** 数据状态:0为正常|其他为删除 **/
    private DataState dataState;

    /** 获取消息ID **/
    public String getId() {
        return id;
    }

    /** 设置消息ID **/
    public void setId(String id) {
        this.id = id;
    }

    /** 获取消息类型(0.通知) **/
    public MessageType getType() {
        return type;
    }

    /** 设置消息类型(0.通知) **/
    public void setType(MessageType type) {
        this.type = type;
    }

    /** 获取群组ID(两人对话时以双方的ID字符连接作为群组ID) **/
    public String getGroupId() {
        return groupId;
    }

    /** 设置群组ID(两人对话时以双方的ID字符连接作为群组ID) **/
    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    /** 获取发送人ID **/
    public Integer getSenderId() {
        return senderId;
    }

    /** 设置发送人ID **/
    public void setSenderId(Integer senderId) {
        this.senderId = senderId;
    }

    /** 获取发送时间 **/
    public Date getSendTime() {
        return sendTime;
    }

    /** 设置发送时间 **/
    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }

    /** 获取接收人ID **/
    public Integer getReceiverId() {
        return receiverId;
    }

    /** 设置接收人ID **/
    public void setReceiverId(Integer receiverId) {
        this.receiverId = receiverId;
    }

    /** 获取标题 **/
    public String getTitle() {
        return title;
    }

    /** 设置标题 **/
    public void setTitle(String title) {
        this.title = title;
    }

    /** 获取内容 **/
    public String getContent() {
        return content;
    }

    /** 设置内容 **/
    public void setContent(String content) {
        this.content = content;
    }

    /** 获取读取时间 **/
    public Date getReadTime() {
        return readTime;
    }

    /** 设置读取时间 **/
    public void setReadTime(Date readTime) {
        this.readTime = readTime;
    }

    /** 获取状态(0.未读|1.已读) **/
    public MessageState getReadState() {
        return readState;
    }

    /** 设置状态(0.未读|1.已读) **/
    public void setReadState(MessageState readState) {
        this.readState = readState;
    }

    /** 获取选项 **/
    public Map<String, Object> getOptions() {
        return options;
    }

    /** 设置选项 **/
    public void setOptions(Map<String, Object> options) {
        this.options = options;
    }

    /** 获取数据状态:0为正常|其他为删除 **/
    public DataState getDataState() {
        return dataState;
    }

    /** 设置数据状态:0为正常|其他为删除 **/
    public void setDataState(DataState dataState) {
        this.dataState = dataState;
    }

    /**
     * 将当前对象转换为子类对象
     *
     * @param clazz 目标类型
     * @return 目标对象
     */
    public <T extends SystemMessageBean> T to(Class<T> clazz) {
        T instance;
        try {
            instance = clazz.newInstance();
        } catch (Exception e) {
            throw new IllegalArgumentException("Failed to create " + clazz.getSimpleName() + " instance.", e);
        }

        instance.setId(this.getId()); // 消息ID
        instance.setType(this.getType()); // 消息类型(0.通知)
        instance.setGroupId(this.getGroupId()); // 群组ID(两人对话时以双方的ID字符连接作为群组ID)
        instance.setSenderId(this.getSenderId()); // 发送人ID
        instance.setSendTime(this.getSendTime()); // 发送时间
        instance.setReceiverId(this.getReceiverId()); // 接收人ID
        instance.setTitle(this.getTitle()); // 标题
        instance.setContent(this.getContent()); // 内容
        instance.setReadTime(this.getReadTime()); // 读取时间
        instance.setReadState(this.getReadState()); // 状态(0.未读|1.已读)
        instance.setOptions(this.getOptions()); // 选项
        instance.setDataState(this.getDataState()); // 数据状态:0为正常|其他为删除
        return instance;
    }

}